<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box{
        width: 200px;
        height: 200px;
    }
    .box1{
        background-color: red;
    }
</style>
<body>
    <div class="box" id="root" >Hello</div>
    <script>
        var root = document.getElementById("root");
        root.id = "roots";

        root.className = "box box1";
        // console.log(root.className);//返回box
        // 增加一个class
        root.classList.add("mybox");
        // 删除一个class
        root.classList.remove("box");
        // 检查当前元素是否包含某个class
        if(root.classList.contains("box1")){
            console.log("有");
        }else{
            console.log("没有");
        }
        //将某个class移入或移除当前元素。
        root.classList.toggle("box1");

        // innerHtml
        // console.log(root.innerHTML = "大家好啊");  //读取
        console.log(root.innerText = "你好啊");
        
        // innerHTML和innerText的区别
        // innerHTML会识别标签
        // innerText会把标签识别成一个字符串
            
        var str = "<a href='https://www.baidu.com'>百度</a>"
        // root.innerHTML = str
        root.innerText = str
        
    </script>
</body>
</html>